<!DOCTYPE html>
<html>

<head>
    <title>TA的粉丝</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <script src="/js/jquery/jquery.min.js"></script>
    <link rel="stylesheet" href="/js/bootstrap/css/bootstrap.css">
    <script src="/js/bootstrap/js/bootstrap.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/message.css"/>
    <script src="/js/plugins/jrender/jrender.js"></script>
    <script src="/js/plugins/jquery-form/jquery.form.js"></script>
    <script src="/js/common.js"></script>
    <link rel="stylesheet" href="/js/plugins/dialog/dialog.css">
    <script src="/js/plugins/dialog/dialog.min.js"></script>
    <script>
        $(function () {
            /*获取用户id*/
            var id = getParams().id;
            var pages;
            var currentPage = 1;
            var fans;

            /*jrender渲染*/
            function renderViews(data) {
                $("#fansList").renderValues(data, {
                    "handle": function (ele, value) {
                        ele.href = "/userProfiles.html?id=" + value;
                    }
                });
            }

            /*发送请求查询该用户的所有粉丝*/
            $.get("/users/" + id + "/fans", function (data) {
                pages = data.pages;
                userFans = data.list;
                renderViews({"list": userFans});
            });


            $(window).scroll(function () {
                if (isEnd()) {
                    if (currentPage < pages) {
                        currentPage++;
                        $.get("/users/" + id + "/fans", {currentPage: currentPage}, function (data) {
                            userFans = $.merge(userFans, data.list);
                            renderViews({"list": userFans});
                        });
                    } else {
                        $(document).dialog({
                            type: "notice",
                            infoText: "没有更多了",
                            autoClose: 1500,
                            position: "center"
                        });
                    }
                }
            });
        })
    </script>
</head>

<body>
<div class="search-head">
    <div class="row nav-search">
        <div class="col">
            <a href="javascript:history.go(-1);">
                <span><i class="fa fa-chevron-left"></i></span>
            </a>
        </div>
        <div class="col">
            <span>粉丝</span>
        </div>
        <div class="col"></div>
    </div>
</div>

<ul class="list-group" id="fansList">
    <div render-loop="list">
        <a render-key="list.id" render-fun="handle">
    <li class="list-group-item d-flex justify-content-between align-items-center">
        <div class="item">
            <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
            <img class="rounded-circle" width=60px height="60px" render-src="list.headImgUrl">
            <span render-html="list.nickName"></span>
        </div>
    </li>
        </a>
    </div>
</ul>
</body>
</html>